package com.lv.common.utils

import com.blankj.utilcode.util.SPStaticUtils
import com.lv.common.BuildConfig


/**
 * 作者： ygx
 * 创建日期：2022/8/3 10:49 PM
 * 签名： 天行健，君子以自强不息；地势坤，君子以厚德载物。
 * -    _              _           _     _   ____  _             _ _
 * -   / \   _ __   __| |_ __ ___ (_) __| | / ___|| |_ _   _  __| (_) ___
 * -  / _ \ | '_ \ / _` | '__/ _ \| |/ _` | \___ \| __| | | |/ _` | |/ _ \
 * - / ___ \| | | | (_| | | | (_) | | (_| |  ___) | |_| |_| | (_| | | (_) |
 * -/_/   \_\_| |_|\__,_|_|  \___/|_|\__,_| |____/ \__|\__,_|\__,_|_|\___/
 *
 * You never know what you can do until you try !
 * ----------------------------------------------------------------
 * 基础baseUrl的配置，可用于dokit的serverHost
 */

/**
 * 获取当前配置的baseHost
 */
fun getBaseHost(): String {
    return if (BuildConfig.DEBUG) {
        val url = SPStaticUtils.getString(SP_KEY_BASE_HOST)
        if (url.isNullOrEmpty()) HOST_DEV else url
//        SPStaticUtils.getString(SP_KEY_BASE_HOST) ?: HOST_PRODUCT
    } else {
        HOST_PRODUCT
    }
}

/**
 * 更新配置host
 */
fun setBaseHost(host: String) {
    SPStaticUtils.put(SP_KEY_BASE_HOST, host)
}

//配置host的key
private const val SP_KEY_BASE_HOST = "sp_key_base_host"

//不同的baseHost，这里演示，所以都写一样的了，
const val HOST_DEV = "https://www.suyiyong.cn:8080/suyiyong/"//开发环境下的host配置
const val HOST_QA = "https://www.suyiyong.cn:8080/suyiyong/"//qa环境的host配置
const val HOST_PRODUCT = "https://www.suyiyong.cn:8080/suyiyong/"//正式配置host
const val canLog = false//正式配置host
//const val HOST_DEV = "http://192.168.3.245:9006/suyiyong/"//开发环境下的host配置
//const val HOST_QA = "http://192.168.3.245:9006/suyiyong/"//qa环境的host配置
//const val HOST_PRODUCT = "http://192.168.3.245:9006/suyiyong/"//正式配置host